﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Domain.Base;
using SmartWMS.Server.FinanceManage.PaymentService.MeetDto;
using SmartWMS.Server.FinanceManage.PaymentService;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.FinanceManage;

namespace SmartWMS.API.Controllers.FinanceManage
{
	/// <summary>
	/// 应付管理控制器
	/// </summary>
	[Route("api/[controller]/[action]")]
	[ApiController]
	[ApiExplorerSettings(GroupName = "Finance")]
	public class PaymentController : ControllerBase
	{
		/// <summary>
		/// 构造函数
		/// </summary>
		private IMeetService _meetService;

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="meetService"></param>
		public PaymentController(IMeetService meetService)
		{
			_meetService = meetService;
		}

		/// <summary>
		/// 添加应付信息
		/// </summary>
		/// <param name="dto">产品Dto</param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult AddMeetAsync(meetsDto dto)
		{
			var meet = _meetService.AddMeetAsync(dto);
			return Ok(meet.Result);
		}

		/// <summary>
		/// 加载支付类别
		/// </summary>
		/// <returns></returns>
		[HttpPost]
		public IActionResult BindPayTypeAsync()
		{
			var type = _meetService.BindPayTypeAsync();
			return Ok(type.Result);
		}

		/// <summary>
		/// 应付列表
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult ShowMeetAsync(queryDto dto)
		{
			var result = _meetService.ShowMeetAsync(dto);
			return Ok(result.Result);
		}

		/// <summary>
		/// 删除报损信息
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult DeletePaymentAsync(KeyEntity id)
		{
			var resault = _meetService.DeletePaymentAsync(id);
			return Ok(resault.Result);
		}

		/// <summary>
		/// 批量删除报损信息
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult BatchDelPaymentAsync(string id)
		{
			var result = _meetService.BatchDelPaymentAsync(id);
			return Ok(result.Result);
		}

		/// <summary>
		/// 反填、查看应付信息
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult ReversePaymentAsync(meetsDto dto)
		{
			var meet = _meetService.ReversePaymentAsync(dto);
			return Ok(meet);
		}

		/// <summary>
		/// 修改产品信息
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult UpdatePaymentAsync(meetsDto dto)
		{
			var update = _meetService.UpdatePaymentAsync(dto);
			return Ok(update.Result);
		}

		/// <summary>
		/// 修改审核状态
		/// </summary>
		/// <param name="dto"></param>
		/// <returns></returns>
		[HttpPost]
		public IActionResult UpdateStateAsync(meetsDto dto)
		{
			var result = _meetService.UpdateStateAsync(dto);
			return Ok(result.Result);
		}
	}

}